<?php

declare(strict_types=1);

namespace app\example\controller;

use app\admin\BaseAdminController;
use think\facade\View;

class Select extends BaseAdminController
{
    public function index()
    {
        View::assign('title', '联动插件/下拉插件');
        View::assign('addJs', addJs(['selectN']));
        return View::fetch();
    }

    public function simple()
    {
        View::assign('title', '简单下拉/下拉插件');
        View::assign('addJs', addJs(['selectS']));
        return View::fetch();
    }

    public function two()
    {
        View::assign('title', 'select2/下拉插件');
        View::assign('addJs', addJs(['select2']));
        return View::fetch();
    }

    public function tree()
    {
        View::assign('title', '下拉树状菜单/下拉插件');
        View::assign('addJs', addJs(['dropdowntree']));
        return View::fetch();
    }

    public function data()
    {
        $json = '[{"id":"1","name":"北京市","children":[{"id":"101","name":"北京市","children":[{"id":"10101","name":"东城区"},{"id":"10102","name":"西城区"}]}]},{"id":"5","name":"河北省","children":[{"id":"501","name":"石家庄市","children":[{"id":"5011","name":"长安区"},{"id":"5012","name":"桥西区"}]},{"id":"502","name":"邯郸市","children":[{"id":"5021","name":"丛台区"},{"id":"5022","name":"邯山区"}]}]}]';
        return json(json_decode($json, true));
    }
}
